Shader "Unlit/Star"
{
    Properties
    {
        _Color ("Star Color", Color) = (1, 1, 1, 1)
        _BendFactor ("Bend Factor", Range(0.0, 1.0)) = 0.5
        _MainTex ("Base (RGB)", 2D) = "white" { }
    }
    SubShader
    {
        Tags
        {
            "RenderType" = "Opaque"
        }
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float4 pos : POSITION;
                float4 color : COLOR;
            };

            float _BendFactor;

            float4 _Color;

            // Function to calculate star shape with bending
            float StarShape(float2 uv, float bendFactor)
            {
                uv = abs(uv); // Reflect to first quadrant
                uv = 1.0 - uv; // Invert for center inward effect
                float d = max(uv.x, uv.y); // Max of x and y for outer bounds of the star

                // Apply bending to the shape
                float bend = pow(d, bendFactor); // Bend effect, adjust with power
                return bend;
            }

            v2f vert(appdata v)
            {
                v2f o;
                float2 uv = v.vertex.xy * 0.5 + 0.5; // Map vertex to [0,1]
                float star = StarShape(uv, _BendFactor);

                o.pos = float4(v.vertex.xy * star, v.vertex.z, 1.0);
                o.color = _Color;
                return o;
            }

            half4 frag(v2f i) : SV_Target
            {
                return i.color;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}